const http = require("http");
const fs = require("fs");

const app = http.createServer((request, response) => {
    let url = request.url
    console.log(url);
    switch (url) {
        case "/":
            var str = fs.readFileSync("./public/2.html");
            response.end(str);
            break;
        case "/index.html":
            var str = fs.readFileSync("./public/index.html");
            response.end(str);
            break;
        case "/admin.html":
            var str = fs.readFileSync("./public/admin.html");
            response.end(str);
            break;
        case "/css/app.css":
            var str = fs.readFileSync("./public/css/app.css");
            response.end(str);
            break;
        default:
            response.setHeader("content-type","charset=utf-8");
            response.end("404 你的地址错误");
    }
})

app.listen(80, () => {
    console.log("80端口打开成功!");
})